/***************************************************************************
 *   Copyright (C) 2006 by Matej Svejda                                    *
 *   mata@aw-modell.at                                                     *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef METRONOME_H
#define METRONOME_H

#include "beats/beat.h"
#include "beats/beepbeat.h"
#include "beats/sdlbeat.h"
#include "visualizations/visualization.h"
#include "visualizations/sinusvisualization.h"
#include "widgets/beatselect.h"

#include <qwidget.h>
#include <qtimer.h>
#include <qpainter.h>
#include <qpopupmenu.h>
#include <klocale.h>
#include <kcmenumngr.h>
#include <kmessagebox.h>
#include <qrect.h>

class Metronome : public QWidget
{
	Q_OBJECT
	public:
		Metronome(QWidget *parent = 0, const char *name = 0);
		~Metronome();
		bool isActive() { return timer.isActive(); };
	
	private:
		QTimer timer;
		
		Beat *beat;
		Beat *beatInstances[3];
		
		int bpm;
		int noteCount;
		int accent;
		int currentBeat;
		
		Visualization *visualization;
		
		QPopupMenu *contextMenu;
		
	protected:
		void paintEvent(QPaintEvent *);
	
	signals:
		void volumeChanged(float volume);
		void visualizationVisibilityChanged(bool visible);
	
	public slots:
		void setAccent(int accentuated);
		void setBPM(int aBPM);
		void start();
		void stop();
		void setBeat(int type);
		void setVisualizationVisibility(bool visible);
		
	private slots:
		void timeout();
		void hideVisualization() { setVisualizationVisibility(false); };
};

#endif
